/*
 * 用户基础类
 * @author: huangzong
 */
const C = require('../common/common.js')

class Factory {
    constructor () {
    }

    /*
   * 打开基础设置页面
   */
    async openAddFactory (row) {
        return await C.openBrowserWindow('/addFactory', row, {
            transparent: true,
            frame: false,
            // openDevTools: true,
            width: 390,
            height: 300,
            useSpa: true,
            spaModel: 'shop'
        })
    }

    // 打开分店和总店的厂商列表
    async openFactoryList () {
        return await C.openBrowserWindow('/openFactoryList', {}, {
            transparent: true,
            frame: false,
            // openDevTools: true,
            width: 850,
            height: 800,
            useSpa: true,
            spaModel: 'shop'
        })
    }

    async addFactory (row) {
        if (row.name == '') {
            C.error('请输入厂商名称')
            return false
        }
        return await C.ajax('/shop/factory/addedit', row, 'post')
    }

    async factoryList (filter) {
        return await C.ajax('/shop/factory/factorylist', filter, 'post')
    }

    async changeFactoryStatus (data) {
        return await C.ajax('/shop/factory/unstop', data, 'post')             
    }
    // 获取所有的厂商列表
    async getAllFactoryList (filter) {
        return await C.ajax('/shop/factory/getAllFactoryList', filter)
    }
}

module.exports = new Factory()